<?php
/**
 * Created by PhpStorm.
 * User: linyh
 * Date: 2015/4/16
 * Time: 23:43
 */

class goodsMTest  extends Activity {
    /** @var  Testify */
    protected $testify;
    function __construct() {
        $this->testify = new Testify();
    }

    protected function getList(){
        $tobeTest=GoodsMode::init();
        $case=new TestifyCase("GoodsMode: getList");
        $case
            ->addData(array(27,), array(null,null,null), "使用shopId=null")
            ->addData(array(24,), array(1,null,null), "使用shopId=1")
            ->addData(array(3,), array(2,null,null), "使用shopId=2")
            ->addData(array(0,), array(0,null,null), "使用shopId=0 一个不存在的值")
            ->addData(array(0,), array('a\'\\pple',null,null), "使用shopId=a'\\pple")
            ->addData(array(19,), array(null,1,null), "label=1")
            ->addData(array(20,), array(null,2,null), "label=2")
            ->addData(array(15,), array(null,3,null), "label=3")
            ->addData(array(5,), array(null,null,5), "goods_cat_id=5")
            ->addData(array(8,), array(null,null,9), "goods_cat_id=9")
            ->addData(array(10,), array(null,null,array(10,11,12,13)), "goods_cat_id=array(10,11,12,13)")
            ->addData(array(27,), array(null,null,null,''), "text=")
            ->addData(array(5,), array(null,null,null,'三方'), "text=三方")
            ->addData(array(5,), array(null,null,null,'三方 复合肥'), "text=三方 复合肥")
            ->addData(array(1,), array(null,null,null,'三方 硝硫基'), "text=三方 硝硫基")
            ->addData(array(16,), array(1,1,null), "使用shopId=1 label=1")
            ->addData(array(3,), array(2,2,null), "使用shopId=2 label=2")
            ->addData(array(1,), array(null,5,5), "使用goods_cat_id=5 label=5")
            ->addData(array(8,), array(null,1,9), "使用goods_cat_id=9 label=1")
            ->addData(array(1,), array(1,5,5), "使用shopId=1 label=5 goods_cat_id=5")
            ->addData(array(3,), array(2,1,array(9,10)), "使用shopId=2 label=2 goods_cat_id=5")
            ->addData(array(2,), array(2,1,array(9,10),"玉米种 4000"), "使用shopId=2 label=2 goods_cat_id=5")
            ->testCase(function($assert, $shop_id, $label_id, $goods_cat_id, $text=null, $orderBy=null, $asc=false, $rows=30, $offset=0)use($case, $tobeTest){
                list($re,$total)= $tobeTest->getList($shop_id, $label_id, $goods_cat_id, $text, $orderBy, $asc, $rows, $offset);
                $case->compare($assert[0]==$total);
            });
        $this->testify->test($case);
    }

    function indexTask(){
        $this->getList();

        $suiteResults=$this->testify->report();
        View::displayAsHtml($suiteResults,"plugin/test/report.php");
    }
}